function getHTTPObject() {
	var httpRequest = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		httpRequest = new XMLHttpRequest();
		if (httpRequest.overrideMimeType) {
			httpRequest.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
  return httpRequest;
}

function ajaxReq(url, id) {
  httpRequest = getHTTPObject();
	if (!httpRequest) {
		return false;
	}
	httpRequest.onreadystatechange = function() {
	  if (httpRequest.readyState == 4) {
		  if (httpRequest.status == 200) {
        document.getElementById(id).innerHTML = httpRequest.responseText;
		  }
	  }
  };
	httpRequest.open('GET', url, true);
	httpRequest.send(null);
}

function ajaxListSongs(url, id) {
  httpRequest = getHTTPObject();
	if (!httpRequest) {
		return false;
	}
	httpRequest.onreadystatechange = function() {
	  if (httpRequest.readyState == 4) {
		  if (httpRequest.status == 200) {
        var retour = '<table><th>title</th><th>url</th>';
        var playlist = httpRequest.responseXML.firstChild;
        for(var iNode = 0 ; iNode < playlist.childNodes.length ; iNode++) {
          var song = playlist.childNodes[iNode];
          var title = song.childNodes[0].firstChild.nodeValue;
          var url   = song.childNodes[1].firstChild.nodeValue;
          retour += '<tr><td>'+title+'</td><td>'+url+'</td></tr>';
        }
        retour += '</table>';
        document.getElementById(id).innerHTML = retour;
		  }
	  }
  };
	httpRequest.open('GET', url, true);
	httpRequest.send(null);
}

